package com.project.common.domain.po;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * @author : [chg]
 * @className : DbBase
 * @description : []
 * @createTime : [2025/7/9 10:30]
 */
@MappedSuperclass
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DbBase {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Schema(description = "创建人")
    @CreatedBy
    @Column(name = "create_by", updatable = false)
    private Long createBy;

    @Schema(description = "创建时间")
    @CreatedDate
    @Column(columnDefinition = "datetime DEFAULT NULL COMMENT '创建时间'")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @JsonIgnore
    @LastModifiedDate
    @Column(columnDefinition = "datetime DEFAULT NULL COMMENT '更新时间'")
    private LocalDateTime updateTime;

    @Schema(description = "更新人")
    @JsonIgnore
    @CreatedBy
    @LastModifiedBy
    @Column(name = "update_by")
    private Long updateBy;

    @Column(columnDefinition = "int DEFAULT NULL COMMENT '删除标志（0-正常,1-删除）'")
    private Integer delFlag;
}
